package com.stox.ui.javafx.list.event.handler;

import javafx.event.EventHandler;
import javafx.scene.input.DragEvent;
import javafx.scene.input.TransferMode;

import org.springframework.stereotype.Component;

import com.stox.dto.WatchList;
import com.stox.dto.intf.AbstractModelNavigable;
import com.stox.ui.javafx.list.widget.WatchlistCell;

@Component
public class WatchlistCellDragOverEventHandler implements
		EventHandler<DragEvent> {

	@Override
	public void handle(DragEvent event) {
		WatchlistCell cell = (WatchlistCell)event.getSource();
		
		if( null != cell && null != cell.getItem() && null != cell.getItem().getType() && 
				cell.getItem().getType().isSubTypeOf(WatchList.WATCHLIST_TYPE) &&
				event.getGestureSource() instanceof AbstractModelNavigable){
			event.acceptTransferModes(TransferMode.ANY);
			event.consume();
		}
	}
}
